var show_num = [];

layui.use(['form'], function () {

    var form = layui.form,
        layer = layui.layer;
    // 登录过期的时候，跳出ifram框架
    if (top.location != self.location) top.location = self.location;
    // 进行登录操作
    form.on('submit(login)', function (data) {
        data = data.field;
        if (data.username == '') {
            layer.msg('用户名不能为空');
            return false;
        }
        if (data.password == '') {
            layer.msg('密码不能为空');
            return false;
        }


        if (data.captcha == '') {
            layer.msg('验证码不能为空');
            return false;
        }
        // 验证码 校验
        let index = layer.msg("正在登录中..", {icon: 16, shade: 0.5})
        let url = "/admin/login/check";
        $(".input-val").val('');
        $.ajax({
            url,
            data,
            type: "POST",
            success(res) {
                layer.close(index);
                if (res.code == 1) {
                    layer.msg('登录成功', {icon: 6, shade: 0.5}, function () {
                        window.location = '/admin/index.html';
                    });
                } else {
                    layer.msg(res.message, {icon: 5, shade: 0.5}, function () {

                    })
                }
            }
        })
        return false;
    });
});
